//
//  StartViewController.m
//  CommentPage
//
//  Created by 欧杨 on 2020/12/3.
//

#import "StartViewController.h"
#import "SignUpViewController.h"
#import "LoginViewController.h"
#import <Masonry.h>

@interface StartViewController ()

@property(strong, nonatomic) UIImageView *icon;
@property(strong, nonatomic) UIButton *login;
@property(strong, nonatomic) UIButton *signup;

@end

@implementation StartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupSubviews];
}

- (void)setupSubviews
{
    UIImage *iconImg = [UIImage imageNamed:@"testImg"];
    _icon = [[UIImageView alloc] initWithImage:iconImg];
    _icon.layer.cornerRadius = 10;
    _icon.layer.shadowColor = UIColor.lightGrayColor.CGColor;
    _icon.layer.masksToBounds = YES;
    _icon.clipsToBounds = YES;
    [self.view addSubview:_icon];
    
    _login = [UIButton buttonWithType:UIButtonTypeSystem];
    [_login.layer setMasksToBounds:YES];
    [_login.layer setCornerRadius:10.0];
    [_login.layer setBorderWidth:1.2];
    _login.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    _login.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    _login.backgroundColor = [UIColor colorWithRed:28 green:134 blue:238 alpha:1.0];
    
    [_login setTitle:@" 登陆 " forState:UIControlStateNormal];
    [_login addTarget:self action:@selector(loginClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_login];
    
    _signup = [UIButton buttonWithType:UIButtonTypeSystem];
    
    [_signup.layer setMasksToBounds:YES];
    [_signup.layer setCornerRadius:10.0];
    [_signup.layer setBorderWidth:1.2];
    _signup.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    _signup.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    _signup.backgroundColor = [UIColor colorWithRed:28 green:134 blue:238 alpha:1.0];
    
    [_signup setTitle:@" 注册 " forState:UIControlStateNormal];
    [_signup addTarget:self action:@selector(signupClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_signup];
    
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@100);
        make.top.equalTo(self.view).offset(200);
        make.centerX.equalTo(self.view);
    }];
    [_login mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.sizeOffset(CGSizeMake(100, 50));
        make.top.equalTo(_icon.mas_bottom).offset(100);
        make.centerX.equalTo(self.view);
    }];
    [_signup mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.sizeOffset(CGSizeMake(100, 50));
        make.top.equalTo(_login.mas_bottom).offset(20);
        make.centerX.equalTo(self.view);
    }];
    
}

#pragma mark -BUTTON

- (void) loginClicked
{
    NSLog(@"login");
    LoginViewController *loginPage = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:loginPage animated:YES];
}

- (void) signupClicked
{
    NSLog(@"signup");
    SignUpViewController *signupPage = [[SignUpViewController alloc] init];
    [self.navigationController pushViewController:signupPage animated:YES];
}

@end
